# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: team/kde <bribbers@disroot.org>

# The group tag is just to easily find this APKBUILD by some scripts for automation
# group=kde-plasma
pkgname=plasma-workspace
pkgver=5.27.10
pkgrel=0
pkgdesc="KDE Plasma Workspace"
# armhf blocked by extra-cmake-modules
arch="all !armhf"
url="https://kde.org/plasma-desktop/"
license="(GPL-2.0-only OR GPL-3.0-only) AND LGPL-2.1-or-later AND GPL-2.0-or-later AND MIT AND LGPL-2.1-only AND LGPL-2.0-or-later AND (LGPL-2.1-only OR LGPL-3.0-only) AND LGPL-2.0-only"
depends="
	accountsservice
	fprintd
	kactivitymanagerd
	kded5
	kinit5
	kio-extras
	kirigami2
	kquickcharts5
	kwin
	milou
	pipewire-session-manager
	plasma-integration
	qt5-qtquickcontrols
	qt5-qttools
	tzdata
	"
depends_dev="
	appstream-dev
	baloo5-dev
	gpsd-dev
	iso-codes-dev
	kactivities-stats5-dev
	kcmutils5-dev
	kcoreaddons5-dev
	kcrash5-dev
	kdbusaddons5-dev
	kdeclarative5-dev
	kded5-dev
	kdelibs4support-dev
	kdesu5-dev
	kglobalaccel5-dev
	kholidays5-dev
	ki18n5-dev
	kidletime5-dev
	kitemmodels5-dev
	kjsembed-dev
	knewstuff5-dev
	knotifyconfig5-dev
	kpackage5-dev
	kpeople5-dev
	krunner5-dev
	kscreenlocker-dev
	ktexteditor5-dev
	ktextwidgets5-dev
	kuserfeedback-dev
	kwallet5-dev
	kwayland5-dev
	kwin-dev
	layer-shell-qt-dev
	libkexiv2-dev
	libkscreen-dev
	libksysguard-dev
	libqalculate-dev
	networkmanager-qt5-dev
	phonon-dev
	plasma-framework5-dev
	prison5-dev
	wayland-protocols
	zlib-dev
	"
makedepends="$depends_dev
	extra-cmake-modules
	kdoctools5-dev
	libxtst-dev
	samurai
	"
checkdepends="xvfb-run"

case "$pkgver" in
	*.90*) _rel=unstable;;
	*) _rel=stable;;
esac
subpackages="$pkgname-dbg $pkgname-dev $pkgname-libs $pkgname-doc $pkgname-lang $pkgname-zsh-completion"
_repo_url="https://invent.kde.org/plasma/plasma-workspace.git"
source="https://download.kde.org/$_rel/plasma/$pkgver/plasma-workspace-$pkgver.tar.xz"
replaces="plasma-desktop<5.24 breeze<5.22.90"

build() {
	# reduce size of debug syms
	CFLAGS="$CFLAGS -O2 -g1" CXXFLAGS="$CXXFLAGS -O2 -g1" \
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DPLASMA_WAYLAND_DEFAULT_SESSION=TRUE
	cmake --build build
}

check() {
	# nightcolortest requires running dbus
	# testdesktop, lookandfeel-kcmTest, test_kio_fonts, servicerunnertest systemtraymodeltest are broken
	# tst_triangleFilter requires plasma-workspace to be installed
	# locationsrunnertest requires a running Wayland environment
	local skipped_tests="("
	local tests="
		nightcolortest
		testdesktop
		lookandfeel-kcmTest
		test_kio_fonts
		servicerunnertest
		systemtraymodeltest
		tst_triangleFilter
		locationsrunnertest
		"
	case "$CARCH" in
		arm*|aarch64|ppc64le) tests="$tests calculatorrunnertest" ;;
	esac
	for test in $tests; do
		skipped_tests="$skipped_tests|$test"
	done
	skipped_tests="$skipped_tests)"
	xvfb-run ctest --test-dir build --output-on-failure -E "$skipped_tests"
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	# We don't ship systemd
	rm -r "$pkgdir"/usr/lib/systemd
}

sha512sums="
de56a884c05101672b5339cd64b345351f602b33b14daa666e18427251980f557dd65fe35f77c3a361507e3372b05e03b713123e2a7cad29c6bba2af2b43b5a7  plasma-workspace-5.27.10.tar.xz
"
